<ui:fragment xmlns="http://w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">




		<p:dataTable value="#{areaUsuarioMB.vendas}" var="v" styleClass="tabela-carrinho"
		paginator="true" paginatorAlwaysVisible="false" rows="20" rowsPerPageTemplate="10,20,30">

			<p:ajax event="rowToggle" listener="#{areaUsuarioMB.onRowToggle}" />

			<p:column headerText="Pedido Nº" sortBy="#{v.id}" styleClass="text-right">
				<h:outputText value="#{v.id}">
				</h:outputText>
			</p:column>

			<p:column headerText="Data">
				<h:outputText value="#{v.dataVenda.time}">
					<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
				</h:outputText>
			</p:column>

			<p:column headerText="Status">
				<h:outputText value="#{v.status.nome}"></h:outputText>
				
					<p:commandLink 
						rendered="#{areaUsuarioMB.renderLinkPagamento(v)}"
						value=" (realizar pagamento)" 
						onclick="window.open('#{v.pagamento.linkPagamento}')"
						 />
			</p:column>

			<p:column headerText="Total" styleClass="text-right">
				<h:outputText value="#{v.totalGeral}">
					<f:convertNumber type="currency" />
				</h:outputText>
			</p:column>

			<p:column headerText="Detalhes" style="width:2%">
				<p:rowToggler />
			</p:column>


			<p:rowExpansion>
				<p:dataTable value="#{areaUsuarioMB.venda.itens}" var="i" styleClass="">

					<p:column headerText="Produto">
						<div class="foto-produto-mini">
							<p:graphicImage
								styleClass="img-foto-produto-mini"
								value="/temp/#{fotoExibirMB.fotoProduto(i.produto).descricao}.jpg" />
						</div>
						<h:outputText value="#{i.produto.nome}" />
					</p:column>

					<p:column headerText="Quantidade" styleClass="text-right">
						<h:outputText value="#{i.quantidade}" />
					</p:column>

					<p:column headerText="Total" styleClass="text-right">
						<h:outputText value="#{i.total}">
							<f:convertNumber type="currency"></f:convertNumber>
						</h:outputText>
					</p:column>

				</p:dataTable>
					
					<div class="row-fluid margin-top">
						<b><h:outputText value="Total do Frete: " /></b>
						<h:outputText value="#{v.totalFrete}" >
							<f:convertNumber type="currency"></f:convertNumber>
						</h:outputText>
					</div>
					<div class="row-fluid">					
						<b><h:outputText value="Previsão de Entrega: " /></b>
						<h:outputText value="#{v.dataEntrega.time}">
							<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
						</h:outputText>
					</div>
					
				</p:rowExpansion>

		</p:dataTable>

</ui:fragment>